package gui;





import guiCode.managerCode;

import javax.swing.JFrame;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.border.LineBorder;
import java.awt.Color;
import java.awt.Toolkit;
import java.awt.Font;
import basic.ClientConsole;

public class ManagerGUI extends JFrame {
	
	
	
	private managerCode mac;
	private ReportGUI report;
	private viewRequestGUI viewRequest;
	private BlockAccessGUI blockAccess;
	private JPanel FirstPanel = null;
	private JButton btnBlockUser = null;
	private JButton btnLogoutSystem;
	private JButton btnRequest=null;
	private JButton btnReport=null;
	
	/**
	 * This method initializes btnBlockUser	
	 */
	private JButton getbtnBlockUser() {
		if (btnBlockUser == null) {
			btnBlockUser = new JButton();
			
			btnBlockUser.setFont(new Font("Tahoma", Font.PLAIN, 11));
			btnBlockUser.setBackground(new Color(192, 192, 192));
			btnBlockUser.setBounds(83, 23, 172, 29);
			btnBlockUser.setText("Block Access To SudentFile");
			 btnBlockUser.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					setContentPane(blockAccess);
				}
			});
		}
		return btnBlockUser;
	}
	
	private JButton getBtnLogoutSystem() {
		if (btnLogoutSystem == null) {
			btnLogoutSystem = new JButton("Logout System");
			/*btnLogoutSystem.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					1.) suppose to update to DB table (user table) to 0 in isLogine col 
					   2.) disconnect connection from server 
					 3.) open messageBox  confirm logout  
				}
			});*/
			btnLogoutSystem.setBackground(Color.LIGHT_GRAY);
			btnLogoutSystem.setBounds(83, 214, 172, 29);
		}
		return btnLogoutSystem;
	}
	
	private JButton getbtnRequest() {
		//if (btnRequest == null) {
			btnRequest = new JButton("View Request");
			btnRequest.setBackground(Color.LIGHT_GRAY);
			btnRequest.setBounds(83, 74, 172, 29);
			btnRequest.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					
					setContentPane(viewRequest);
				}
			});
		//}
		return btnRequest;
	}
	private JButton getbtnReport() {
		if (btnReport == null) {
			btnReport = new JButton("Report");
			btnReport.setBackground(Color.LIGHT_GRAY);
			btnReport.setBounds(83, 136, 172, 35);
			btnReport.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					setContentPane(report);
				}
			});
			
		}
		return btnReport;
	}
	
	/**
	 * This is the default constructor
	 */
	public ManagerGUI() {
		super();
		initialize();
	}
	public ManagerGUI(ClientConsole conn, Integer whoAmI) {

	   super();
	    mac=new managerCode(); 
	    this.setConnection(conn);
	    this.setID(whoAmI);
		initialize();
		

		
	}
	/**
	 * This method initializes AcademicFrame 
	 */

	private void initialize() {
		
		//this.setResizable(false);
		this.setSize(800, 395);
		this.setContentPane(getFirstPanel());
		this.setTitle("Manager Access Screen");
		
		this.blockAccess=new BlockAccessGUI(580, 395,  mac.getConnection());
		this.report=new ReportGUI(580, 395, mac.getConnection() );
		this.viewRequest=new viewRequestGUI (800, 395, mac.getConnection());
		
		this.setVisible( true ); 
		
		blockAccess.btnBack.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				blockAccess.blockStatusPanel.setVisible(false);
				setContentPane(FirstPanel);
				
				
			}
		});
		report.btnBack.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setContentPane(FirstPanel);
			}
		});
		viewRequest.btnBack.addActionListener(new ActionListener() {
		   	public void actionPerformed(ActionEvent arg0) {
		   		setContentPane(FirstPanel);
		   	}
		   });
	}
	
	/**
	 * This method initializes FirstPanel
	 */
	private JPanel getFirstPanel() {
		if (FirstPanel == null) {
			FirstPanel = new JPanel();
			FirstPanel.setForeground(Color.GRAY);
			FirstPanel.setLayout(null);
			FirstPanel.add(getbtnBlockUser());
			FirstPanel.add(getbtnRequest());
			FirstPanel.add(getbtnReport());
			FirstPanel.add(getBtnLogoutSystem());
			
			
		
		}
		return FirstPanel; 
	}
	
	void setID(Integer whoAmI){
		mac.setID(whoAmI);
	}
	void setConnection(ClientConsole conn){
		
		
		mac.setConnection(conn);
	}

}
	
